<template>
  <s-type-manage
      :busin-type="businType"
      :page-title="pageTitle"
      @type-selected="handleTypeSelected"
  />
</template>

<script setup>
import { ref, onMounted } from 'vue';

const businType = ref('');
const pageTitle = ref('');

onMounted(() => {
  const pages = getCurrentPages();
  const currentPage = pages[pages.length - 1];
  const { businType: type, pageTitle: title } = currentPage.options;
  
  businType.value = type || '';
  pageTitle.value = title || '类型管理';
});

const handleTypeSelected = (type) => {
  // 根据业务类型存储不同的数据
  const storageKey = businType.value === 'RELATIONSHIP' ? 'selectedRelationshipType' : 'selectedEventType';
  
  // 将选中的类型数据存储到本地存储
  uni.setStorageSync(storageKey, {
    id: type.id,
    name: type.name,
    icon: type.icon
  });
  
  // 返回上一页
  uni.navigateBack();
};
</script>

<style lang="scss" scoped>
// 如果需要添加样式
</style> 